import { Image, Input, Text, View, WebView } from '@tarojs/components';
import Taro, { getCurrentInstance } from '@tarojs/taro';
import React, { Component } from 'react';
import './order-body.less';
import * as T from '../types';
import actions from '../actions/index';
import { connect } from 'react-redux';
import { store2Props } from '../selectors';
import { _, OrderWrapper, WMkit, immutable } from 'wmkit';
import FormSelect from '@/pages/common/form-select';
import FormItem from '@/pages/common/form-item';
import ImageListScroll from '@/pages/common/image-list-scroll';
import Price from '@/pages/common/goods/price';
import moment from 'dayjs';
import FormSwitch from '@/pages/common/form/form-switch';
import { IndexModuleSpuIdResponse } from '../../../../../webapi/IndexController';
//@ts-ignore
let isH5 = __TARO_ENV === 'h5';
type OrderStatusProps = T.IProps & T.OrderStatusProps;
const noneImg = require('../img/none.png');
const cv = require('../img/cv.png');
import arrow from '@/assets/image/common/arrow.png';

@connect<Partial<OrderStatusProps>, T.OrderStatusState>(store2Props, actions)
export default class OrderBody extends Component<Partial<OrderStatusProps>, T.OrderStatusState> {
  constructor(props: OrderStatusProps) {
    super(props);
    // this.setState({
    //   inputPoints: 0,
    // });

    this.state = {
      inputPoints: 0,
    };
  }

  componentDidMount(): void {
    let { points = {} } = (this.props && this.props.main) || {};
    this.setState({
      inputPoints: points.usePoint,
    });
  }

  render() {
    let {
      main,
      actions = {},
      actions: { action },
    } = this.props;
    let orderWrapper = OrderWrapper(immutable.fromJS(main.detail));
    const {
      pointConfig = {},
      isBookingSaleGoods,
      detail = {},
      localData = {},
      points = {},
      isPayBalance,
      goodsTotalPrice,
      pointsOrder,
      chargeAccount,
      // 二维码/网页二维码
      qrcode,
      webQrcode,
      // 卡号/卡密
      cardNumber,
      cardSecret,
      // 是否是虚拟订单
      virtualGoods,
      customerCollection
    } = main || {};
    const { confirmCoupon = {} } = localData;
    const { totalPoint, showPointInput, maxPoint, usePoint } = points;
    // 积分设置打开且为订单抵扣
    let pointsUsageFlag = pointConfig.status == 1 && pointConfig.pointsUsageFlag == 0 ? true : false;
    let earnestPrice = 0,
      swellPrice = 0,
      tailStartTime;
    const tradePrice = detail.tradePrice;
    const tradeState = detail.tradeState;
    // 是否设置膨胀金
    let hasSwellPrice = false;
    if (detail && JSON.stringify(detail) != '{}') {
      earnestPrice = tradePrice.earnestPrice; //定金
      swellPrice = tradePrice.swellPrice; //膨胀
      hasSwellPrice = _.sub(swellPrice, earnestPrice) == 0 ? false : true;
      tailStartTime = tradeState.tailStartTime;
    }
    let couponPrice;
    if (detail?.tradeState?.flowState == 'WAIT_PAY_EARNEST' || detail?.tradeState?.flowState == 'WAIT_PAY_TAIL') {
      couponPrice = confirmCoupon.couponTotalPrice || 0;
    } else {
      couponPrice = detail?.tradePrice ? orderWrapper.couponPrice() : 0;
    }
    //尾款，膨胀金可能大于商品价格，导致尾款为负数
    let tailPrice = _.sub(_.sub(_.sub(goodsTotalPrice, swellPrice), actions._pointToMoney(usePoint)), couponPrice);
    tailPrice = tailPrice < 0 ? 0 : tailPrice;
    // 尾款需要加上运费
    tailPrice = tailPrice + tradePrice?.deliveryPrice || 0;

    const _calc = (button: Array<string>) => {
      return function (flow: string, pay: string) {
        return button[0] === flow && button[1] === pay;
      };
    };

    const isShowReturn = () => {
      const canReturnFlag = orderWrapper.canReturnFlag(); //订单状态
      const flowState = orderWrapper.flowState(); //订单状态
      const payState = orderWrapper.payState(); //订单状态
      const applyReturnButtons = [
        ['AUDIT', 'PAID'],
        ['DELIVERED_PART', 'PAID'],
        ['DELIVERED', 'PAID'],
        ['COMPLETED', 'PAID'],
      ];
      if (canReturnFlag && applyReturnButtons.filter((button) => _calc(button)(flowState, payState)).length > 0) {
        return true;
      }
    };

    return (
      main.detail && (
        <View className="commonForm" style={{ width: '100%' }}>
          <View className="body1">
            {!!cardNumber && !!cardSecret && (
              <View className='cardNumberBox'>
                <View
                  className='cardCopy'
                  onClick={() => {
                    Taro.setClipboardData({
                      data: cardNumber,
                    }).then((res) => {
                      // web端手动提示，小程序端有默认提示
                      if (Taro.getEnv() == Taro.ENV_TYPE.WEB) {
                        Taro.showToast({
                          title: '卡号已复制',
                          icon: 'success',
                        });
                      }
                    });
                  }}
                >
                  <Text className='cardNumber'>
                    卡号：{cardNumber}
                  </Text>
                  <Image className='cvimg' src={cv} />
                </View>

                <View
                  className='cardCopy'
                  onClick={() => {
                    Taro.setClipboardData({
                      data: cardSecret,
                    }).then((res) => {
                      // web端手动提示，小程序端有默认提示
                      if (Taro.getEnv() == Taro.ENV_TYPE.WEB) {
                        Taro.showToast({
                          title: '卡密已复制',
                          icon: 'success',
                        });
                      }
                    });
                  }}
                >
                  <Text>
                    卡密：{cardSecret}
                  </Text>
                  <Image className='cvimg' src={cv} />
                </View>
                
              </View>
            )}
            {!!cardNumber && !cardSecret && (
              <View className='cardNumberBox'
                onClick={() => {
                  Taro.setClipboardData({
                    data: cardNumber,
                  }).then((res) => {
                    // web端手动提示，小程序端有默认提示
                    if (Taro.getEnv() == Taro.ENV_TYPE.WEB) {
                      Taro.showToast({
                        title: '卡密已复制',
                        icon: 'success',
                      });
                    }
                  });
                }}
              >
                <Text className='cardNumber'>卡密：{cardNumber}</Text>
              </View>
            )}
            {!!qrcode && (
              <View className='qrcodeBox'>
                <Image className="qrcode" src={qrcode} />
              </View>
            )}
            {!!webQrcode && (
              <WebView
                id="webQrcode"
                src={webQrcode}
                className='webQrcode'
              />
            )}
            {!!chargeAccount && (
              <View className='recharge-box'>
                <Text className='recharge-title'>充值号码</Text>
                <Input
                  type='text'
                  className='recharge-text'
                  placeholder={chargeAccount}
                  disabled
                />
              </View>
            )}
            <View className="sku-head">
              <View
                className="head-top"
              // onClick={() => {
              //   Taro.navigateTo({
              //     url:
              //       WMkit.channelType() == '2' && WMkit.inviteeId() != ''
              //         ? `/pages/package-B/distribution/store/social-c/shop-index-c/index?inviteeId=${WMkit.inviteeId()}`
              //         : `/pages/package-A/store/store-main/index?storeId=${orderWrapper.storeId()}`,
              //   });
              // }}
              >
                {orderWrapper.isSelf() && !(WMkit.channelType() == '2' && WMkit.inviteeId() != '') ? (
                  <View className="self-sales">自营</View>
                ) : null}
                {WMkit.channelType() == '2' && WMkit.inviteeId() != ''
                  ? `${main.detail.distributorName}的${main.detail.shopName || '小店'}`
                  : orderWrapper.storeName()}
              </View>
            </View>
            <View
            // 废弃 订单详情页商品点击跳转到商品详情页
            // onClick={() => {
            //   if (main.promotionOrder) {
            //     Taro.navigateTo({
            //       url: `/pages/package-C/order/order-sku-list/index?tid=${orderWrapper.orderNo()}&type=promotionOrder`,
            //     });
            //   } else {
            //       Taro.navigateTo({
            //         url: `/pages/package-C/order/order-sku-list/index?tid=${orderWrapper.orderNo()}`,
            //       });
            //   }
            // }}
            >
              <View className="middle-detail">
                {orderWrapper
                  .tradeItems()
                  .toJS()
                  .map((item, index) => (
                    <View
                      key={index}
                      className="product-item"
                      onClick={() => {
                        // 小c通过小B的店铺内分享链接进来购买的商品
                        if (
                          WMkit.inviteeId() &&
                          !WMkit.isDistributorFlag() &&
                          WMkit.channelType() == '2' &&
                          item.distributionGoodsAudit == '2'
                        ) {
                          Taro.navigateTo({
                            url: `/pages/package-B/distribution/shop/socia-details/index?id=${WMkit.inviteeId()}&goodsId=${item.spuId
                              }&skuId=${item.skuId}`,
                          });
                        } else {
                          // 积分商品详情，跳转到积分商品页面
                          if (pointsOrder) {
                            Taro.navigateTo({
                              url: `/pages/package-B/goods/goods-details/index?skuId=${item.skuId}&pointsGoodsId=${item.pointsGoodsId}`,
                            });
                          } else {
                            Taro.navigateTo({
                              url: `/pages/package-B/goods/goods-details/index?skuId=${item.skuId}`,
                            });
                          }
                        }
                      }}
                    >
                      <Image className="img-item" key={item.oid} src={item.pic ? item.pic : noneImg} />
                      <View className="order-body-detail">
                        <View style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between' }}>
                          <View className="name">{item.skuName}</View>
                        </View>
                        <View className="price">
                          <View className="specDetails">{item.specDetails ? item.specDetails : ''}</View>
                          {main.pointsOrder ? (
                            <Price price={0} buyPoint={item.points} />
                          ) : (
                            <Price price={_.addZero(item.price)} buyPoint={item.buyPoint} />
                          )}
                        </View>
                        <View className="right">
                          {item.rids && item.rids.length > 0 && (
                            <View
                              className="btn"
                              onClick={(e) => {
                                e.stopPropagation();
                                if (item.rids.length === 1) {
                                  Taro.navigateTo({
                                    url: `/pages/package-C/order/return-detail/index?id=${item.rids[0]}`,
                                  });
                                } else {
                                  Taro.navigateTo({
                                    url: `/pages/package-C/order/refund-list/index?rids=${item.rids.join(',')}`,
                                  });
                                }
                              }}
                            >
                              售后进度
                            </View>
                          )}
                          {!virtualGoods && (
                            <>
                              {isShowReturn() && !customerCollection && (
                                <View
                                  className="btn"
                                  onClick={(e) => {
                                    e.stopPropagation();
                                    if (item.canReturnNum > 0) {
                                      Taro.navigateTo({
                                        url: `/pages/package-C/order/return-refund/return-first-step/index?tid=${main.tid}&skuId=${item.skuId}`,
                                      });
                                    } else {
                                      Taro.showToast({
                                        title: '无可退商品',
                                        icon: 'none',
                                        duration: 2000,
                                      });
                                    }
                                  }}
                                >
                                  退货退款
                                </View>
                              )}
                              <View
                                className="btn"
                                onClick={(e) => {
                                  e.stopPropagation();
                                  actions.action.addGoods(item);
                                }}
                              >
                                加购
                              </View>
                            </>
                          )}
                        </View>
                      </View>
                    </View>
                  ))}
                {orderWrapper
                  .gifts()
                  .toJS()
                  .map((item, index) => (
                    <View className="product-item" key={index}>
                      <Image className="img-item" key={item.oid} src={item.pic ? item.pic : noneImg} />
                      <View className="order-body-detail">
                        <View className="gift-con">
                          <View className="gift-sku-icon">
                            <Text className="gift-sku-text">赠品</Text>
                          </View>
                          <View className="name">
                            <Text style={{ opacity: '0' }} className="gift-sku-text">
                              赠品
                            </Text>
                            {item.skuName}
                          </View>
                        </View>
                        {/*<View className="name">*/}
                        {/*  <View className="gifts">赠品</View>*/}
                        {/*</View>*/}
                        <View className="specDetails">{item.specDetails}</View>
                        <View className="price">
                          <Price price={_.addZero(item.price)} />
                        </View>
                        {!virtualGoods && (
                          <View className="right">
                            <View
                              className="btn"
                              onClick={(e) => {
                                e.stopPropagation();
                                actions.action.addGoods(item);
                              }}
                            >
                              加购
                            </View>
                          </View>
                        )}
                      </View>
                    </View>
                  ))}
              </View>
            </View>
            <View>
              {!isBookingSaleGoods && (
                <View>
                  <FormSelect
                    labelName="付款记录"
                    placeholder=""
                    formStyle={{ padding: '10px 5px' }}
                    textStyle={{ fontWeight: 500 }}
                    inputStyle={__TARO_ENV == 'h5' ? { color: 'rgba(0,0,0,0.8)', fontWeight: 500, opacity: '1' } : {}}
                    // selected={{
                    //   key: '1',
                    //   value: orderWrapper.orderPayState(),
                    // }}
                    value={orderWrapper.orderPayState()}
                    onClick={() => {
                      this._toPayRecord(orderWrapper.orderNo(), orderWrapper.orderPayState());
                    }}
                  />
                  {!virtualGoods && (
                    <FormSelect
                      labelName="发货记录"
                      formStyle={{ padding: '10px 5px' }}
                      textStyle={{ fontWeight: 500 }}
                      placeholder=""
                      inputStyle={__TARO_ENV == 'h5' ? { color: 'rgba(0,0,0,0.8)', fontWeight: 500, opacity: '1' } : {}}
                      // selected={{
                      //   key: '1',
                      //   value: orderWrapper.orderDeliveryState(),
                      // }}
                      value={orderWrapper.orderDeliveryState()}
                      onClick={() => {
                        this._toShipRecord(orderWrapper.orderNo(), orderWrapper.orderDeliveryState());
                      }}
                      iconVisible={this._isIconVisible(orderWrapper.orderDeliveryState())}
                    />
                  )}
                </View>
              )}
              {!main.pointsOrder && (
                <FormSelect
                  labelName="发票信息"
                  formStyle={{ padding: '10px 5px' }}
                  textStyle={{ fontWeight: 500 }}
                  inputStyle={__TARO_ENV == 'h5' ? { color: 'rgba(0,0,0,0.8)', fontWeight: 500, opacity: '1' } : {}}
                  placeholder=""
                  // selected={{
                  //   key: '1',
                  //   value: orderWrapper.orderInvoice(),
                  // }}
                  value={orderWrapper.orderInvoice()}
                  onClick={() => {
                    this._toInvoice(orderWrapper.orderNo());
                  }}
                  iconVisible={this._isInvoiceVisible(orderWrapper.orderInvoice())}
                />
              )}
              {orderWrapper.buyerRemark() != '无' ? (
                <FormItem
                  styles={{ padding: '10px 5px' }}
                  labelName="订单备注"
                  textStyle={{ textAlign: 'right', fontWeight: 500, color: 'rgba(0,0,0,0.8)' }}
                  placeholder={orderWrapper.buyerRemark()}
                />
              ) : null}

              {/* <FormItem
                  labelName="卖家备注"
                  textStyle={{ textAlign: 'right', fontWeight: 500, color: 'rgba(0,0,0,0.8)' }}
                  placeholder={orderWrapper.sellerRemark()}
                /> */}
              {(main.detail.tradeItems && main.detail.tradeItems[0].isFlashSaleGoods) ||
                orderWrapper.encloses().length == 0 ? (
                ''
              ) : (
                <ImageListScroll imageList={orderWrapper.encloses()} labelName="订单附件" />
              )}
            </View>
          </View>
          {isBookingSaleGoods && (
            <View className="body1">
              <View className="mb10 top-border">
                {orderWrapper.orderState() == '待支付定金' ? (
                  <FormItem
                    labelName="使用优惠券"
                    styles={{ padding: '10px 5px' }}
                    leftStyle={{ fontSize: '12px' }}
                    textStyle={{ textAlign: 'right', color: 'rgba(0,0,0,0.8)' }}
                    placeholder="尾款阶段可用"
                  />
                ) : (
                  orderWrapper.orderState() == '待支付尾款' && (
                    <View
                      className="order-store-item"
                      onClick={async () => {
                        // 待支付尾款并且尾款未提交订单
                        if (orderWrapper.orderState() == '待支付尾款' && !isPayBalance) {
                          await actions.action._urlChange(1);
                        }
                      }}
                    >
                      <Text className="order-item-label">使用优惠券</Text>
                      <View className="store-item-right">
                        <Text className="item-text">
                          ¥{confirmCoupon.couponTotalPrice ? actions._addZero(confirmCoupon.couponTotalPrice) : '0.00'}
                        </Text>
                        {orderWrapper.orderState() == '待支付尾款' && !isPayBalance && (
                          <Image className="arrow-img" src={arrow} />
                        )}
                      </View>
                    </View>
                  )
                )}

                {/* 待支付定金、已创建支付尾款快照、状态不等于待支付尾款情况下显示使用积分 */}
                {orderWrapper.orderState() == '待支付定金' ? (
                  <FormItem
                    labelName="使用积分"
                    styles={{ padding: '10px 5px' }}
                    leftStyle={{ fontSize: '12px' }}
                    textStyle={{ textAlign: 'right', color: 'rgba(0,0,0,0.8)' }}
                    placeholder="尾款阶段可用"
                  />
                ) : (
                  orderWrapper.orderState() == '待支付尾款' &&
                  pointsUsageFlag &&
                  !isPayBalance && (
                    <View className="order-store-item">
                      <View className="order-store-point">
                        <View className="point-con">
                          <Text className="order-item-label">使用积分</Text>
                          {showPointInput && (
                            <View className="point-box">
                              <Input
                                type="number"
                                value={usePoint.toString()}
                                // 通过value无法控制输入最大值，达到最大依然能够输入，结合长度来控制，默认长度为140
                                maxlength={usePoint >= maxPoint ? maxPoint.toString().length : 140}
                                onInput={({ detail: { value } }) => {
                                  const point = Number(value) >= maxPoint ? maxPoint : Number(value);
                                  action.commonChange('main.points.usePoint', point);
                                  // this.setState({
                                  //   inputPoints: point,
                                  // });
                                  return point;
                                }}
                                className="point-input"
                                placeholder="点击输入"
                              />
                              <Text className="order-item-label" decode>
                                积分&nbsp;&nbsp;&nbsp;抵扣
                              </Text>
                              <Text className="use-point-price">¥{actions._pointToMoney(usePoint)}</Text>
                            </View>
                          )}
                          <FormSwitch
                            title=""
                            checked={showPointInput}
                            disabled={maxPoint <= 0}
                            onChange={(bool) => {
                              if (maxPoint > 0) {
                                action.commonChange([
                                  { paths: 'main.points.showPointInput', value: bool },
                                  { paths: 'main.points.usePoint', value: 0 },
                                ]);
                              }
                            }}
                          />
                        </View>
                        <View className="order-point-con">
                          <Text className="item-input-text">共</Text>
                          <Text className="item-input-price">{totalPoint}</Text>
                          <Text className="item-input-text">积分，</Text>
                          {showPointInput ? (
                            <View className="order-point-con">
                              <Text className="item-input-text">最多可用</Text>
                              <Text className="item-input-price">{maxPoint ? maxPoint : 0}</Text>
                              <Text className="item-input-text">积分抵扣</Text>
                              <Text className="item-input-price">
                                ¥{actions._pointToMoney(maxPoint ? maxPoint : 0)}
                              </Text>
                            </View>
                          ) : (
                            <View className="order-point-con">
                              <Text className="item-input-text">达到</Text>
                              <Text className="item-input-price">{pointConfig.overPointsAvailable}</Text>
                              <Text className="item-input-text">积分后可用于下单抵扣</Text>
                            </View>
                          )}
                        </View>
                      </View>
                    </View>
                  )
                )}
                {orderWrapper.orderState() != '待支付定金' && orderWrapper.orderState() != '待支付尾款' && !virtualGoods ? (
                  <FormSelect
                    labelName="发货记录"
                    formStyle={{ padding: '10px 5px' }}
                    textStyle={{ fontWeight: 500 }}
                    placeholder=""
                    inputStyle={__TARO_ENV == 'h5' ? { color: 'rgba(0,0,0,0.8)', fontWeight: 500, opacity: '1' } : {}}
                    // selected={{
                    //   key: '1',
                    //   value: orderWrapper.orderDeliveryState(),
                    // }}
                    value={orderWrapper.orderDeliveryState()}
                    onClick={() => {
                      this._toShipRecord(orderWrapper.orderNo(), orderWrapper.orderDeliveryState());
                    }}
                    iconVisible={this._isIconVisible(orderWrapper.orderDeliveryState())}
                  />
                ) : null}
                <FormItem
                  labelName="尾款通知手机号"
                  styles={{ padding: '10px 0px 10px 5px' }}
                  leftStyle={{ fontSize: '12px' }}
                  textStyle={{ textAlign: 'right', color: 'rgba(0,0,0,0.8)' }}
                  placeholder={detail.tailNoticeMobile}
                />
              </View>
            </View>
          )}
          {!main.pointsOrder ? (
            <View className="body2">
              <View className="total-price mb10">
                {!isBookingSaleGoods && (
                  <View className="total-list">
                    <Text className="price">应付金额</Text>
                    <Text className="price-color">￥{orderWrapper.totalPrice()}</Text>
                  </View>
                )}
                <View className="total-list">
                  <Text className="price3">商品金额</Text>
                  <Text className="price2">￥{orderWrapper.goodsPrice()}</Text>
                </View>

                {/*非店铺内购买商品，展示原本营销优惠*/}
                {!(WMkit.inviteeId() && WMkit.isShop()) && !isBookingSaleGoods && (
                  <View>
                    {orderWrapper.marketingDiscountPrice() != 0 && (
                      <View className="total-list">
                        <Text className="price3">活动优惠</Text>
                        <Text className="price2">
                          -￥
                          {orderWrapper.marketingDiscountPrice()}
                        </Text>
                      </View>
                    )}
                  </View>
                )}
                {pointsUsageFlag
                  ? orderWrapper.points() != 0 && (
                    <View className="total-list">
                      <Text className="price3">使用积分</Text>
                      {orderWrapper.points() ? (
                        <Text className="price2">{orderWrapper.points()}</Text>
                      ) : (
                        <Text className="price2">0</Text>
                      )}
                    </View>
                  )
                  : orderWrapper.pointsPrice() != 0 && (
                    <View className="total-list">
                      <Text className="price3">积分抵扣</Text>
                      <Text className="price2">
                        -￥
                        {orderWrapper.pointsPrice()}
                      </Text>
                    </View>
                  )}
                {orderWrapper.couponPrice() != 0 && (
                  <View className="total-list">
                    <Text className="price3">优惠券</Text>
                    <Text className="price2">
                      -￥
                      {orderWrapper.couponPrice()}
                      {/*66*/}
                    </Text>
                  </View>
                )}
                {!virtualGoods && (
                  <View className="total-list">
                    <Text className="price3">配送费用</Text>
                    <Text className="item-text">￥{orderWrapper.deliveryPrice()}</Text>
                  </View>
                )}
                {orderWrapper.commission() > 0 && !isBookingSaleGoods && WMkit.isDistributor() && (
                  <View className="total-list">
                    <Text className="price3">预计返利</Text>
                    <Text className="price2">￥{orderWrapper.commission()}</Text>
                  </View>
                )}
                {isBookingSaleGoods && (
                  <View className="total-list">
                    <Text className="price3">定金</Text>
                    <View style={{ flexDirection: 'column' }}>
                      <Text className="item-text" style={{ textAlign: 'end' }}>
                        -¥{earnestPrice ? earnestPrice.toFixed(2) : '0'}
                      </Text>
                      {hasSwellPrice && (
                        <Text className="swellPrice">定金膨胀 ¥{swellPrice ? swellPrice.toFixed(2) : '0'}</Text>
                      )}
                    </View>
                  </View>
                )}
                {/* {isBookingSaleGoods && hasSwellPrice && (
                  <View className="total-list">
                    <Text className="price3"></Text>
                    <Text className="swellPrice">定金膨胀 ¥{swellPrice ? swellPrice.toFixed(2) : '0'}</Text>
                  </View>
                )} */}
                {isBookingSaleGoods && (
                  <View className="total-list">
                    <Text className="price3">尾款</Text>
                    <View style={{ flexDirection: 'column' }}>
                      <Text className="item-text" style={{ textAlign: 'end' }}>
                        ¥{tailPrice.toFixed(2)}
                      </Text>
                      {orderWrapper.orderState() == '待支付尾款' && (
                        <Text className="item-text tailStartTime">
                          {moment(tailStartTime).format('M月DD日 HH:mm')}开始支付尾款
                        </Text>
                      )}
                    </View>
                  </View>
                )}
                {/* {isBookingSaleGoods && (
                  <View className="total-list">
                    <Text className="price3"></Text>
                    {orderWrapper.orderState() == '待支付尾款' && (
                      <Text className="item-text tailStartTime">
                        {moment(tailStartTime).format('M月DD日 HH:mm')}开始支付尾款
                      </Text>
                    )}
                  </View>
                )} */}
              </View>
            </View>
          ) : (
            <View className="order-point-wrap">
              <Text className="order-point-label">订单积分</Text>
              <Text className="order-point-num">{orderWrapper.points()}</Text>
            </View>
          )}
        </View>
      )
    );
  }

  /**
   * 付款记录页
   */
  async _toPayRecord(tid: string, pay: string) {
    await Taro.navigateTo({ url: `/pages/package-C/order/pay-detail/index?tid=${tid}` });
  }

  /**
   * 发票记录
   */
  _toInvoice = (id: string) => {
    const {
      main: { detail, promotionOrder },
    } = this.props;
    let orderWrapper = OrderWrapper(immutable.fromJS(detail));
    if (orderWrapper.orderInvoice() == '不需要发票') {
      return;
    } else if (promotionOrder) {
      Taro.navigateTo({ url: `/pages/package-C/order/invoice-info/index?tid=${id}&type=${1}` });
    } else {
      Taro.navigateTo({ url: `/pages/package-C/order/invoice-info/index?tid=${id}&type=${0}` });
    }
  };

  _toShipRecord = (id: string, state: string) => {
    let { main } = this.props;
    if (state == '未发货') {
      return;
    } else {
      if (main.promotionOrder) {
        Taro.navigateTo({ url: `/pages/package-C/order/ship-record/index?tid=${id}&type=1` });
      } else {
        Taro.navigateTo({ url: `/pages/package-C/order/ship-record/index?tid=${id}&type=0` });
      }
    }
  };

  /**
   * 发货记录icon是否显示
   * @param state
   * @returns {boolean}
   * @private
   */
  _isIconVisible = (state: string) => {
    return state !== '未发货';
  };

  /**
   * 发票信息是否显示
   */
  _isInvoiceVisible = (invoice: string) => {
    return invoice !== '不需要发票';
  };
}
